package com.zx._10_设计模式.创建型模式.单例模式;

/**
 * 单例模式--4. 静态内部类(数据安全的)
 */
public class Singleton4 {

    private Singleton4() {
    }

    public synchronized static Singleton4 getInstance() {
        return SingletonHolder.INSTANCE;
    }

    // 让其他类创建好对象
    private static class SingletonHolder {

        private static final Singleton4 INSTANCE = new Singleton4();
    }

}